package com.imc.action;

import java.util.ArrayList;

import org.springframework.stereotype.Component;

import com.imc.daoImpl.LoginDaoImpl;

//@Controller("loginAction")
//@Scope("prototype")
@Component("loginAction")
public class LoginAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	// 登录的dao
	private LoginDaoImpl loginDaoImpl = new LoginDaoImpl();
	// 返回错误信息
	private String message;

	@Override
	public String execute() throws Exception {
		String username = (String) this.getRequest().getParameter("username");
		String pass = this.getRequest().getParameter("passw");
		System.out.println(username);
		ArrayList userList = loginDaoImpl.isLogin(username);
		if (userList.size() != 0) {
			for (int i = 0; i < userList.size(); i++) {
				System.out.println(userList.get(i));
			}
		}
		if (1 == 1) {
			return "success";
		}
		{
			message = "对不起，用户名或密码错了!";
			this.getSession().setAttribute("msg", message);
			return "errors";
		}

	}

}
